#pragma once
#include<iostream>
#include<functional>
#include<unordered_map>

//任务
void Upload(){
    cout << "This is Upload Task, Task_Code: " << 0 << endl;
}

void Download(){
    cout << "This is Download Task, Task_Code: " << 1 << endl;
}

void Scan(){
    cout << "This is Scan Task, Task_Code: " << 2 << endl;
}

void Copy(){
    cout << "This is Copy Task, Task_Code: " << 3 << endl;
}

void Update(){
    cout << "This is Update Task, Task_Code: " << 4 << endl;
}

void Log(){
    cout << "Show log..." << " " <<  "Task_Code: " << 5 << endl;
}

//任务总数
const int total_num = 6;


class Task_List{
public:
    Task_List()
        :_total_task_num(total_num)
    {}

    void Register(int code, function<void()> f){
        _Opr.insert({code, f});
    }

    int Get_taskcode(){
        int code = rand() % _total_task_num;
        return code;
    }

    void Execute_task(int code){
        _Opr[code]();
    }

private:
    unordered_map<int, function<void()>> _Opr;
    int _total_task_num;
};